gdkglcontext: Only emit opengl debug calls if GDK_DEBUG=gl-debug
authorAlexander Larsson <alexl@redhat.com>
Wed, 24 Apr 2019 13:23:32 +0000 (15:23 +0200)
committerAlexander Larsson <alexl@redhat.com>
Thu, 25 Apr 2019 09:36:23 +0000 (11:36 +0200)
This avoids a potential performance cost in the non-debug case.

gdk/gdk.c
gdk/gdkglcontext.c
gdk/gdkinternals.h

index e094b3465a534c41d96fa0ff842e5fd33799201e..29acab541583b46ee8c72ad4b1b5dfb76b2ae6ab 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -145,6 +145,7 @@ static const GDebugKey gdk_debug_keys[] = {
   { "gl-texture-rect", GDK_DEBUG_GL_TEXTURE_RECT },
   { "gl-legacy",       GDK_DEBUG_GL_LEGACY },
   { "gl-gles",         GDK_DEBUG_GL_GLES },
+  { "gl-debug",        GDK_DEBUG_GL_DEBUG },
   { "vulkan-disable",  GDK_DEBUG_VULKAN_DISABLE },
   { "vulkan-validate", GDK_DEBUG_VULKAN_VALIDATE }
 };
index 9ac8628ca0ae50185e7a640e24198f4d0046377b..3f93d83f428ef1bb97ca331831b96498cf5057c5 100644 (file)
@@ -106,6 +106,7 @@ typedef struct {
   guint has_gl_framebuffer_blit : 1;
   guint has_frame_terminator : 1;
   guint has_khr_debug : 1;
+  guint use_khr_debug : 1;
   guint has_unpack_subimage : 1;
   guint has_debug_output : 1;
   guint extensions_checked : 1;
@@ -441,7 +442,7 @@ gdk_gl_context_push_debug_group (GdkGLContext *context,
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
 
-  if (priv->has_khr_debug)
+  if (priv->use_khr_debug)
     glPushDebugGroupKHR (GL_DEBUG_SOURCE_APPLICATION, 0, -1, message);
 }
 
@@ -454,7 +455,7 @@ gdk_gl_context_push_debug_group_printf (GdkGLContext *context,
   gchar *message;
   va_list args;
 
-  if (priv->has_khr_debug)
+  if (priv->use_khr_debug)
     {
       va_start (args, format);
       message = g_strdup_vprintf (format, args);
@@ -470,7 +471,7 @@ gdk_gl_context_pop_debug_group (GdkGLContext *context)
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
 
-  if (priv->has_khr_debug)
+  if (priv->use_khr_debug)
     glPopDebugGroupKHR ();
 }
 
@@ -482,7 +483,7 @@ gdk_gl_context_label_object (GdkGLContext *context,
 {
   GdkGLContextPrivate *priv = gdk_gl_context_get_instance_private (context);
 
-  if (priv->has_khr_debug)
+  if (priv->use_khr_debug)
     glObjectLabel (identifier, name, -1, label);
 }
 
@@ -497,7 +498,7 @@ gdk_gl_context_label_object_printf  (GdkGLContext *context,
   gchar *message;
   va_list args;
 
-  if (priv->has_khr_debug)
+  if (priv->use_khr_debug)
     {
       va_start (args, format);
       message = g_strdup_vprintf (format, args);
@@ -990,6 +991,8 @@ gdk_gl_context_check_extensions (GdkGLContext *context)
 
   display = gdk_draw_context_get_display (GDK_DRAW_CONTEXT (context));
 
+  if (priv->has_khr_debug && GDK_DISPLAY_DEBUG_CHECK (display, GL_DEBUG))
+    priv->use_khr_debug = TRUE;
   if (!priv->use_es && GDK_DISPLAY_DEBUG_CHECK (display, GL_TEXTURE_RECT))
     priv->use_texture_rectangle = TRUE;
   else if (has_npot)
index 35b5cccedd5c9d5421b6234a24e32374b93fb7e6..3e0cc5be9ad0de1db661cbf55142edcc8440a8d4 100644 (file)
@@ -63,8 +63,9 @@ typedef enum {
   GDK_DEBUG_GL_TEXTURE_RECT = 1 << 14,
   GDK_DEBUG_GL_LEGACY       = 1 << 15,
   GDK_DEBUG_GL_GLES         = 1 << 16,
-  GDK_DEBUG_VULKAN_DISABLE  = 1 << 17,
-  GDK_DEBUG_VULKAN_VALIDATE = 1 << 18
+  GDK_DEBUG_GL_DEBUG        = 1 << 17,
+  GDK_DEBUG_VULKAN_DISABLE  = 1 << 18,
+  GDK_DEBUG_VULKAN_VALIDATE = 1 << 19
 } GdkDebugFlags;
 
 extern guint _gdk_debug_flags;